package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.Departments;
import com.itgaoshu.hospitalproject.bean.Doctor;
import com.itgaoshu.hospitalproject.bean.Registeredtype;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface DoctorMapper {
    //查询医生列表的方法
    List<Doctor> doctorList(Doctor doctor);
    //删除医生的方法
    @Delete("delete from doctor where doctorId=#{doctorId}")
    int deleteDoctor(int doctorId);
    //根据id查询该医生是否还有病人
    @Select("select count(r.reportId) from report r ,doctor d where r.doctor=d.doctorId and r.doctor=#{doctorId} and d.dstate=0 and r.state=1")
    int count(int doctorId);
    //查询所有科室的方法
    @Select("select * from departments")
    List<Departments> findAllDepartments();
    //查询所有挂号类型的方法
    @Select("select * from registeredtype")
    List<Registeredtype> findAllRegisteredtype();
    //添加医生的方法
    @Insert("insert into doctor(doctorName,departmentId,registeredId,dstate)values(#{doctorName},#{departmentId},#{registeredId},#{dstate})")
    int addDoctor(Doctor doctor);
    //修改医生的方法
    @Update("update doctor set doctorname=#{doctorName},departmentId=#{departmentId},registeredId=#{registeredId},dstate=#{dstate} where doctorId=#{doctorId}")
    int editDoctor(Doctor doctor);
}













